<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  <script type="text/javascript">
$(function() {
	init();
});
function init(){
	var ip = $("#upIp").val();
	var serviceName = $("#upServiceName").val();
	$.ajax({
		type:"POST",
		url: path+'cluster/showCells',
		data:{serviceName:serviceName,ip:ip},
		success: function(result){
			for(var cell in result.result[serviceName].parameter){
				 var appendStr = "<div class='form-group'><label for='inputEmail3' class='col-sm-2 control-label'>"+cell+"</label>";
				 appendStr += "<div class='col-sm-3'><input id='"+cell+"' type='text' class='form-control' id='port' placeholder='PORT' value='"+result.result[serviceName].parameter[cell]+"'></div></div>";
				 $("#cellDiv").append(appendStr);
			 } 
		}
	});
}
function updateCellsNow(){
	var ip = $("#upIp").val();
	var serviceName = $("#upServiceName").val();
	$.ajax({
		cache:false,
		async:false,
		type:"POST",
		url: path+'cluster/showCells',
		data:{serviceName:serviceName,ip:ip},
		success: function(result){
			var keyArray =new Array();
			var valueArray =new Array();
			var i = 0;
			for(var cell in result.result[serviceName].parameter){
				keyArray[i] = cell;
				valueArray[i] = $("#"+cell).val();
				i  = parseInt(i)+1;
			}
			if(keyArray.length>0){
				$.ajax({
					cache:false,
					async:false,
					type:"POST",
					dataType: "json",
					traditional: true,  
					url: path+'cluster/updateCells',
					data:{keyArray:keyArray,valueArray:valueArray,serviceName:serviceName,ip:ip},
					success: function(result2){
						if(result2){
							alert("修改成功");
						}
					}
				});
			}
		}
	});
}
</script>
	<div class="box-body form-horizontal">
	<div id="cellDiv">
      </div>
        <div class="box-footer">
           <a type="submit" class="btn btn-info" onclick="updateCellsNow()">更新</a>
           <input type="hidden" id="upIp" value="${ip }" />
           <input type="hidden" id="upServiceName" value="${serviceName }"/>
        </div>
	</div>


<input id="servId" type="hidden" value="2">